
package com.paul.util;

import com.paul.constant.UtilConstant;

public class StringUtil {
	public static boolean isEmpty(String str) {
		if (str == null || str.trim().equals(""))
			return true;

		return false;
	}

	public static String cStr(Object o) {
		if (o == null)
			return UtilConstant.EMPTY_VALUE;
		else
			return o.toString();
	}
	
	public String stringJoin(Object[] objArray, String separator) {
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < objArray.length; i++) {
			buffer.append(separator).append(cStr(objArray[i]));
		}
		return buffer.deleteCharAt(0).toString();
	}

	public static String htmlEncode(String html) {
		html = html.replaceAll("&", "&amp;");
		html = html.replaceAll(">", "&gt;");
		html = html.replaceAll("<", "&lt;");
		html = html.replaceAll("\"", "&quot;");
		return html;

	}
}
